/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.logiclander.whozwho.data.dao.hibernate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Check;
import org.hibernate.annotations.GenericGenerator;


/**
 *
 * @author logiclander
 */
@Entity
@Table( name = "MEMBERSHIPS" )
@Check(constraints = "membership_type IN ('P', 'G')")
public class Membership {
  private long sid;
  private Role role;
  private Datastore datastore;
  private String datastoreKey;
  private char memberType;
  private boolean activeIndicator;
  private char type;

  @Id
  @GeneratedValue(generator = "increment")
  @GenericGenerator(name = "increment", strategy = "increment")
  @Column(name = "membership_sid", nullable = false)
  public Long getSid() {
    return sid;
  }

  public void setSid(long sid) {
    this.sid = sid;
  }

  @ManyToOne
  @JoinColumn(name="role_sid")
  public Role getRole() {
    return role;
  }

  public void setRole(Role role) {
	  this.role = role;
  }

  @ManyToOne
  @JoinColumn(name="datastore_sid")
  public Datastore getDatastore() {
    return datastore;
  }

  public void setDatastore(Datastore datastore) {
	  this.datastore = datastore;
  }

  @Column(name = "datastore_key", nullable = false)
  public String getDatastoreKey() {
    return datastoreKey;
  }

  public void setDatastoreKey(String datastoreKey) {
    this.datastoreKey = datastoreKey;
  }

  @Column(name = "member_type", nullable = false)
  public char getMemberType() {
    return memberType;
  }

  public void setMemberType(char memberType) {
    this.memberType = memberType;
  }

  @Column(name = "active_indicator", nullable = false)
  public boolean getActiveIndicator() {
    return activeIndicator;
  }

  public void setActiveIndicator(boolean activeIndicator) {
    this.activeIndicator = activeIndicator;
  }

  @Column(name = "membership_type", length = 1, nullable = false)
  public char getType() {
	  return type;
  }
  
  public void setType(char type) {
	  this.type = type;
  }
  
}
